package com.pllandxzx.controller;


import com.pll.dto.ResponseDto;
import com.pllandxzx.service.FeeRulesService;
import com.pllandxzx.vo.FeeRuleVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName FeeRulesController
 * @Description TODO 抽成规则管理
 * @Author 小鹿
 * @Date 2025/6/8 11:19
 */

@Tag(name = "收费规则管理")
@RestController
@RequestMapping("/feeRules")
public class FeeRulesController
{
    @Autowired
    private FeeRulesService feeRulesService;
    /**
     * 查询所有收费规则 并分页返回
     */

    @Operation(description = "获取所有收费规则")
    @GetMapping("/getAllFeeRules")
    public ResponseDto getAllFeeRules(@RequestParam("page")int page,@RequestParam("pageSize")int pageSize)
    {
        return feeRulesService.getAllFeeRules(page,pageSize);
    }

    /**
     * 删除收费规则
     */
    @Operation(description = "删除收费规则")
    @DeleteMapping("/deleteFeeRules/{id}")
    public ResponseDto deleteFeeRules(@PathVariable("id") Integer id)
    {
        return feeRulesService.deleteFeeRules(id);
    }

    /**
     * 新增收费规则
     */
    @Operation(description = "新增收费规则")
    @PostMapping("/addFeeRule")
    public ResponseDto addFeeRule(@RequestBody FeeRuleVo data)
    {
        System.out.println(data);
        return feeRulesService.addFeeRule(data);
    }

    /**
     * 修改收费规则
     */
    @Operation(description = "修改收费规则")
    @PutMapping("/updateFeeRule/{id}")
    public ResponseDto updateFeeRule(@PathVariable("id")Integer id,@RequestBody FeeRuleVo data)
    {
        System.out.println(data);
        return feeRulesService.updateFeeRule(id,data);
    }
}